<?php
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));


    $query=$mysqli->query("SELECT qiuid FROM joinqiu where openid='".$openid."'  limit 0,1 ");
    if($query->num_rows>0){
        $getDzId=$query->fetch_assoc();
        $queryQiu=$mysqli->query("SELECT openid FROM qdui where id='".$getDzId['qiuid']."' limit 0,1 ");
        if($queryQiu->num_rows>0){
            $getQiu=$queryQiu->fetch_assoc();
            $qiuOpenid=$getQiu['openid'];
            //通知队长
            $queryQiu=$mysqli->query("SELECT id FROM message where myid='".$qiuOpenid."' and fromid='".$openid."' limit 0,1 ");
            if($queryQiu->num_rows>0){
                $mysqli->query("update message set isread=0  where myid='".$qiuOpenid."' and fromid='".$openid."' ");
            }else{
                $mysqli->query("insert into message(myid,fromid,type,createtime) values('".$qiuOpenid."','".$openid."','1','".date("Y-m-d H:i:s")."')  ");
            }
        }
    }
    $mysqli->close();
    
    echo json_encode(array('s'=>'y'));
}

